/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 运营活动公共数据
	/// module : structs
	/// </summary>
	public class OperationEventPOD : IPOD 
    {
        public readonly static Func<OperationEventPOD> FACTORY = () => new OperationEventPOD();
		public static Func<OperationEventPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        ///  活动配置Id
        /// </summary>
		public int eventCfgId;
		/// <summary>
        ///  活动subdata cfgId
        /// </summary>
		public int dataCfgId;
		/// <summary>
        ///  活动状态
        /// </summary>
		public OperationEventStatus status;
		/// <summary>
        ///  活动开始时间(秒)
        /// </summary>
		public int startTime;
		/// <summary>
        ///  活动结束时间(秒)
        /// </summary>
		public int endTime;
		/// <summary>
        ///  活动关闭时间(秒)
        /// </summary>
		public int closeTime;
		/// <summary>
        ///  活动额外数据
        /// </summary>
		public string extJsonData;
		/// <summary>
        ///  活动唯一id
        /// </summary>
		public string eventUid;
		/// <summary>
        ///  活动开启总次数
        /// </summary>
		public int totalOpenCount;
		
		
		
		/*-- constructors --*/
		public OperationEventPOD() {}
		public OperationEventPOD(int eventCfgId, int dataCfgId, OperationEventStatus status, int startTime, int endTime, int closeTime, string extJsonData, string eventUid, int totalOpenCount) {
			this.eventCfgId = eventCfgId;
			this.dataCfgId = dataCfgId;
			this.status = status;
			this.startTime = startTime;
			this.endTime = endTime;
			this.closeTime = closeTime;
			this.extJsonData = extJsonData;
			this.eventUid = eventUid;
			this.totalOpenCount = totalOpenCount;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(eventCfgId);
            _out.Write_int(dataCfgId);
            _out.Write_byte((sbyte)status);
            _out.Write_int(startTime);
            _out.Write_int(endTime);
            _out.Write_int(closeTime);
            _out.Write_string(extJsonData);
            _out.Write_string(eventUid);
            _out.Write_int(totalOpenCount);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            eventCfgId = _in.Read_int();
            if(!_in.HasRemaining()) return;
            dataCfgId = _in.Read_int();
            if(!_in.HasRemaining()) return;
            status = (OperationEventStatus)_in.Read_byte();
            if(!_in.HasRemaining()) return;
            startTime = _in.Read_int();
            if(!_in.HasRemaining()) return;
            endTime = _in.Read_int();
            if(!_in.HasRemaining()) return;
            closeTime = _in.Read_int();
            if(!_in.HasRemaining()) return;
            extJsonData = _in.Read_string();
            if(!_in.HasRemaining()) return;
            eventUid = _in.Read_string();
            if(!_in.HasRemaining()) return;
            totalOpenCount = _in.Read_int();
        }
		
		public OperationEventPOD Clone() {
            OperationEventPOD o = DynamicFactory();
            o.eventCfgId = eventCfgId;
            o.dataCfgId = dataCfgId;
            o.status = status;
            o.startTime = startTime;
            o.endTime = endTime;
            o.closeTime = closeTime;
            o.extJsonData = extJsonData;
            o.eventUid = eventUid;
            o.totalOpenCount = totalOpenCount;
            return o;
        }
        
        public void Clear() {
            eventCfgId = default;
            dataCfgId = default;
            status = default;
            startTime = default;
            endTime = default;
            closeTime = default;
            extJsonData = default;
            eventUid = default;
            totalOpenCount = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "OperationEventPOD [";
			str += "eventCfgId=";
			str += eventCfgId;
			str += ", dataCfgId=";
			str += dataCfgId;
			str += ", status=";
			str += status;
			str += ", startTime=";
			str += startTime;
			str += ", endTime=";
			str += endTime;
			str += ", closeTime=";
			str += closeTime;
			str += ", extJsonData=";
			str += extJsonData;
			str += ", eventUid=";
			str += eventUid;
			str += ", totalOpenCount=";
			str += totalOpenCount;
			str += "]";
			return str;
		}
		
	}
}